<template>
	<view style="touch-action: none;">
		<!-- <view v-if="list.length> 0">
			<wyb-table ref="table" :headers="headers" :default-col-width="220" :contents="list" :font-size="[25]"
				:first-line-fixed="true" header-bg-color="#EFEFF4" first-col-bg-color="#fff" :cancelable='false'/>
		</view>
		 -->
		<view class="publicTabel" v-if="list.length> 0">
			<uni-table border stripe emptyText="暂无更多数据">
				<!-- 表头行 -->
				<uni-tr>
					<uni-th align="center" v-for="item in headers" :key="item.key">{{item.label}}</uni-th>
					<uni-th align="center" v-if="isDel">操作</uni-th>
				</uni-tr>
				<!-- 表格数据行 -->
				<uni-tr v-for="item in list" :key="item.id">
					<uni-td align="center" v-for="data in headers" :key="data.key">{{item[data.key]}}</uni-td>
					<uni-td align="center" v-if="isDel">
						<roc-btn type="error" text="删除" @click.native="handleDel(item)"></roc-btn>
					</uni-td>
				</uni-tr>
			</uni-table>
		</view>
		<view style="text-align: center;padding-bottom: 50px;" v-else>
			<image src="@/static/img/nullData.png" style="width: 160px;height: 160px;"></image>
			<view class="">
				暂无数据
			</view>
		</view>
		<!-- 删除 -->
		<u-modal :show="modalShow" :showCancelButton="true" title="删除" content="确定删除吗?" @confirm="confirm"
			@cancel="modalShow = false" @close="modalShow = false"></u-modal>
	</view>
</template>

<script>
	import {
		doDel
	} from '@/api/car.js'
	export default {
		data() {
			return {
				headers: [],
				list: [],
				isDel: false,
				modalShow: false,
				formId: {}
			}
		},
		methods: {
			showEdit(data) {
				this.headers = data.headers,
					this.list = data.list
				if (data.type === "isDel") {
					this.isDel = true;
				}
			},
			handleDel(row) {
				this.formId = row;
				this.modalShow = true;
			},
			// 确定删除
			async confirm() {
				const {
					data
				} = await doDel({
					id: this.formId.id
				})
				this.$u.toast(data.msg);
				 this.$emit('fetch-data')
				this.modalShow = false;
			},
		}
	}
</script>

<style>
	.publicTabel {
		margin-top: 11px;
	}
</style>
